using System;
using System.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Xml;
using System.Reflection;
using System.Configuration;


using WorkflowProcesses = Scenario.WorkflowEngine.DataModel.WorkflowProcesses;
using WorkflowRelevantData = Scenario.WorkflowEngine.DataModel.WorkflowRelevantData;
using WorkflowParticipantsData = Scenario.WorkflowEngine.DataModel.WorkflowParticipantsData;

using WAPI = Scenario.WAPI;
using log4net;
using log4net.Config;
using Scenario.WorkflowEngine.DataBase;
using Scenario.WorkflowEngine.DataModel.WorkflowProcesses;
using Scenario.WAPI;
using Scenario.WorkflowEngine;
using Scenario.Tools.UI.Controls.Workflow;

namespace Scenario.Modeler
{
	/// <summary>
	/// Descrizione di riepilogo per MainForm.
	/// </summary>
	public class MainForm : System.Windows.Forms.Form
	{
		
		// Variables
        private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.OpenFileDialog openFileDialog1;
		private System.Windows.Forms.ContextMenu shapeShortcutMenu;
		private System.Windows.Forms.MenuItem shortcutMenu;
        private System.Windows.Forms.SaveFileDialog saveFileDialog1;
		private System.Windows.Forms.MenuItem menuItem14;
		private System.Windows.Forms.MenuItem menuItem17;
		private System.Windows.Forms.MenuItem menuItem21;
		private System.Windows.Forms.MenuItem menuItem22;
		private System.Windows.Forms.MenuItem menuCheck;
		private System.Windows.Forms.MenuItem menuTutorial;
        private System.Windows.Forms.MenuItem menuManual;
        private System.Windows.Forms.MenuItem menuAboutModeler;
        private System.Windows.Forms.MenuItem menuItem15;
		private System.Windows.Forms.MenuItem menuApplications;
		private System.Windows.Forms.MenuItem menuDataTypes;
		private System.Windows.Forms.MenuItem menuPartecipants;
        private System.Windows.Forms.MenuItem menuManageCheck;
        private System.Windows.Forms.MenuItem menuItem2;
        private IContainer components;
        private System.Windows.Forms.MenuItem menuItem7;

		/// <summary>
		/// Utilizzate per collezionare i partecipanti ai workflow disegnati.
		/// </summary>
		private WorkflowParticipantsData.XMLRoles xmlRoles;
		private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
		private System.Windows.Forms.MenuItem menuItem23;
		private System.Windows.Forms.MenuItem mnuXSDEditor;
		private System.Windows.Forms.MenuItem menuXMLDB;
        private System.Windows.Forms.MenuItem menuXSDInference;
		private System.Windows.Forms.MenuItem mnuSendFeedBack;
		private System.Windows.Forms.MenuItem menuItem25;

		/// <summary>
		/// Utilizzato per collezionare i workflow associati ai singoli fogli.
		/// E' indispensabile collezionare workflow in quanto non tutte le infos
		/// valorizzabile con il modeler sono associate a shapes e quindi vengono
		/// memorizzare direttamente sul workflow.
		/// </summary>
        public WorkflowProcesses.XMLWorkflows xmlWorkflows;

        private ToolStrip toolStrip1;

        private ToolStripSeparator toolStripSeparator1;
        private ToolStripButton toolStripButton1;
        private ToolStripButton toolStripButton3;
        private ToolStripButton toolStripButton2;
        private ToolStripButton toolStripPartecipants;
        private ToolStripButton toolStripButton5;
        private ToolStripButton toolStripButton6;
        private ToolStripSeparator toolStripSeparator2;
        private ToolStripButton toolStripButton7;
        private ToolStripSeparator toolStripSeparator3;
        private ToolStripSplitButton toolStripButton8;
        private ToolStripMenuItem creatToolStripMenuItem;
        private ToolStripMenuItem eseguiToolStripMenuItem;
        private ToolStripMenuItem apriToolStripMenuItem;
        private ToolStripMenuItem restartToolStripMenuItem;
        private ToolStripButton toolStripButton4;
        private MenuItem menuItem1;
        private MenuItem menuItem3;
        private MenuItem menuItem4;
        private MenuItem menuItem5;
        private MenuItem menuEnd;
        private StatusStrip statusStrip1;
        private Panel pnlBottom;
        private Scenario.Tools.UI.Controls.ListControls.ActivityList activityList1;
        private MenuItem menuItem8;
        private MenuItem mnuStartTemplate;
        private Panel panel1;
        private Scenario.Tools.UI.Controls.ListControls.WorkflowList workflowList1;


		private static readonly ILog log = LogManager.GetLogger(typeof(MainForm));

		public MainForm()
		{
			string sConfigFile = ((Assembly.GetEntryAssembly()).GetName()).Name+
																".exe.config";

			XmlConfigurator.Configure(new System.IO.FileInfo(sConfigFile));

			//
			// Necessario per il supporto di Progettazione Windows Form
			//
			InitializeComponent();

			log.Info("Inizializing Scenario Engine");
		}

		
		
		
		/// <summary>
		/// Pulire le risorse in uso.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Codice generato da Progettazione Windows Form
		/// <summary>
		/// Metodo necessario per il supporto della finestra di progettazione. Non modificare
		/// il contenuto del metodo con l'editor di codice.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
            this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
            this.menuItem5 = new System.Windows.Forms.MenuItem();
            this.menuEnd = new System.Windows.Forms.MenuItem();
            this.menuItem21 = new System.Windows.Forms.MenuItem();
            this.menuCheck = new System.Windows.Forms.MenuItem();
            this.menuManageCheck = new System.Windows.Forms.MenuItem();
            this.menuItem22 = new System.Windows.Forms.MenuItem();
            this.menuApplications = new System.Windows.Forms.MenuItem();
            this.menuDataTypes = new System.Windows.Forms.MenuItem();
            this.menuPartecipants = new System.Windows.Forms.MenuItem();
            this.menuItem8 = new System.Windows.Forms.MenuItem();
            this.mnuStartTemplate = new System.Windows.Forms.MenuItem();
            this.menuItem14 = new System.Windows.Forms.MenuItem();
            this.menuManual = new System.Windows.Forms.MenuItem();
            this.menuTutorial = new System.Windows.Forms.MenuItem();
            this.menuItem17 = new System.Windows.Forms.MenuItem();
            this.mnuSendFeedBack = new System.Windows.Forms.MenuItem();
            this.menuItem25 = new System.Windows.Forms.MenuItem();
            this.menuAboutModeler = new System.Windows.Forms.MenuItem();
            this.menuItem2 = new System.Windows.Forms.MenuItem();
            this.menuItem15 = new System.Windows.Forms.MenuItem();
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            this.menuItem3 = new System.Windows.Forms.MenuItem();
            this.menuItem4 = new System.Windows.Forms.MenuItem();
            this.menuItem7 = new System.Windows.Forms.MenuItem();
            this.menuItem23 = new System.Windows.Forms.MenuItem();
            this.mnuXSDEditor = new System.Windows.Forms.MenuItem();
            this.menuXMLDB = new System.Windows.Forms.MenuItem();
            this.menuXSDInference = new System.Windows.Forms.MenuItem();
            this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            this.shapeShortcutMenu = new System.Windows.Forms.ContextMenu();
            this.shortcutMenu = new System.Windows.Forms.MenuItem();
            this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
            this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
            this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
            this.toolStripPartecipants = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton5 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton6 = new System.Windows.Forms.ToolStripButton();
            this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
            this.toolStripButton7 = new System.Windows.Forms.ToolStripButton();
            this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
            this.toolStripButton8 = new System.Windows.Forms.ToolStripSplitButton();
            this.creatToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.eseguiToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.apriToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.restartToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.statusStrip1 = new System.Windows.Forms.StatusStrip();
            this.pnlBottom = new System.Windows.Forms.Panel();
            this.panel1 = new System.Windows.Forms.Panel();
            this.workflowList1 = new Scenario.Tools.UI.Controls.ListControls.WorkflowList();
            this.toolStrip1.SuspendLayout();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuItem5,
            this.menuItem21,
            this.menuItem14,
            this.menuItem7});
            // 
            // menuItem5
            // 
            this.menuItem5.Index = 0;
            this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuEnd});
            this.menuItem5.Text = "File";
            // 
            // menuEnd
            // 
            this.menuEnd.Index = 0;
            this.menuEnd.Text = "Exit";
            this.menuEnd.Click += new System.EventHandler(this.menuEnd_Click);
            // 
            // menuItem21
            // 
            this.menuItem21.Index = 1;
            this.menuItem21.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuCheck,
            this.menuManageCheck,
            this.menuItem22,
            this.menuApplications,
            this.menuDataTypes,
            this.menuPartecipants,
            this.menuItem8,
            this.mnuStartTemplate});
            this.menuItem21.Text = "Workflow";
            // 
            // menuCheck
            // 
            this.menuCheck.Index = 0;
            this.menuCheck.Text = "Check";
            this.menuCheck.Click += new System.EventHandler(this.menuCheck_Click);
            // 
            // menuManageCheck
            // 
            this.menuManageCheck.Index = 1;
            this.menuManageCheck.Text = "Manage Check";
            this.menuManageCheck.Click += new System.EventHandler(this.menuManageCheck_Click);
            // 
            // menuItem22
            // 
            this.menuItem22.Index = 2;
            this.menuItem22.Text = "-";
            // 
            // menuApplications
            // 
            this.menuApplications.Index = 3;
            this.menuApplications.Text = "Applications";
            this.menuApplications.Click += new System.EventHandler(this.menuApplications_Click);
            // 
            // menuDataTypes
            // 
            this.menuDataTypes.Index = 4;
            this.menuDataTypes.Text = "DataTypes";
            this.menuDataTypes.Click += new System.EventHandler(this.menuDataTypes_Click);
            // 
            // menuPartecipants
            // 
            this.menuPartecipants.Index = 5;
            this.menuPartecipants.Text = "Partecipants";
            this.menuPartecipants.Click += new System.EventHandler(this.menuPartecipants_Click);
            // 
            // menuItem8
            // 
            this.menuItem8.Index = 6;
            this.menuItem8.Text = "-";
            // 
            // mnuStartTemplate
            // 
            this.mnuStartTemplate.Index = 7;
            this.mnuStartTemplate.Text = "Start Template";
            this.mnuStartTemplate.Click += new System.EventHandler(this.mnuStartTemplate_Click);
            // 
            // menuItem14
            // 
            this.menuItem14.Index = 2;
            this.menuItem14.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuManual,
            this.menuTutorial,
            this.menuItem17,
            this.mnuSendFeedBack,
            this.menuItem25,
            this.menuAboutModeler,
            this.menuItem2,
            this.menuItem15,
            this.menuItem1});
            this.menuItem14.Text = "Help";
            // 
            // menuManual
            // 
            this.menuManual.Index = 0;
            this.menuManual.Text = "Table of contents";
            this.menuManual.Click += new System.EventHandler(this.menuManual_Click);
            // 
            // menuTutorial
            // 
            this.menuTutorial.Index = 1;
            this.menuTutorial.Text = "Tutorial";
            this.menuTutorial.Click += new System.EventHandler(this.menuTutorial_Click);
            // 
            // menuItem17
            // 
            this.menuItem17.Index = 2;
            this.menuItem17.Text = "-";
            // 
            // mnuSendFeedBack
            // 
            this.mnuSendFeedBack.Index = 3;
            this.mnuSendFeedBack.Text = "Send a FeedBack";
            this.mnuSendFeedBack.Click += new System.EventHandler(this.mnuSendFeedBack_Click);
            // 
            // menuItem25
            // 
            this.menuItem25.Index = 4;
            this.menuItem25.Text = "-";
            // 
            // menuAboutModeler
            // 
            this.menuAboutModeler.Index = 5;
            this.menuAboutModeler.Text = "About Scenario Consolle";
            this.menuAboutModeler.Click += new System.EventHandler(this.menuAboutModeler_Click);
            // 
            // menuItem2
            // 
            this.menuItem2.Index = 6;
            this.menuItem2.Text = "FAQ on the Web";
            // 
            // menuItem15
            // 
            this.menuItem15.Index = 7;
            this.menuItem15.Text = "-";
            // 
            // menuItem1
            // 
            this.menuItem1.Index = 8;
            this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuItem3,
            this.menuItem4});
            this.menuItem1.Text = "About Sponsors";
            // 
            // menuItem3
            // 
            this.menuItem3.Index = 0;
            this.menuItem3.Text = "Adaptive Software srl";
            // 
            // menuItem4
            // 
            this.menuItem4.Index = 1;
            this.menuItem4.Text = "Product and Process srl";
            // 
            // menuItem7
            // 
            this.menuItem7.Index = 3;
            this.menuItem7.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuItem23});
            this.menuItem7.Text = "SuperUser";
            // 
            // menuItem23
            // 
            this.menuItem23.Index = 0;
            this.menuItem23.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.mnuXSDEditor,
            this.menuXMLDB,
            this.menuXSDInference});
            this.menuItem23.Text = "XML";
            // 
            // mnuXSDEditor
            // 
            this.mnuXSDEditor.Index = 0;
            this.mnuXSDEditor.Text = "XSD Editor";
            this.mnuXSDEditor.Click += new System.EventHandler(this.mnuXSDEditor_Click);
            // 
            // menuXMLDB
            // 
            this.menuXMLDB.Index = 1;
            this.menuXMLDB.Text = "XML DB";
            this.menuXMLDB.Click += new System.EventHandler(this.menuXMLDB_Click);
            // 
            // menuXSDInference
            // 
            this.menuXSDInference.Index = 2;
            this.menuXSDInference.Text = "XSD Inference";
            this.menuXSDInference.Click += new System.EventHandler(this.menuXSDInference_Click);
            // 
            // shapeShortcutMenu
            // 
            this.shapeShortcutMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.shortcutMenu});
            // 
            // shortcutMenu
            // 
            this.shortcutMenu.Index = 0;
            this.shortcutMenu.Text = "Attachments";
            // 
            // toolStrip1
            // 
            this.toolStrip1.Enabled = false;
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton1,
            this.toolStripButton3,
            this.toolStripButton2,
            this.toolStripSeparator1,
            this.toolStripButton4,
            this.toolStripPartecipants,
            this.toolStripButton5,
            this.toolStripButton6,
            this.toolStripSeparator2,
            this.toolStripButton7,
            this.toolStripSeparator3,
            this.toolStripButton8});
            this.toolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(801, 38);
            this.toolStrip1.TabIndex = 8;
            this.toolStrip1.Text = "toolStrip1";
            // 
            // toolStripButton1
            // 
            this.toolStripButton1.Image = global::Scenario.Tools.Consolle.Properties.Resources.toolStripButton1_Image;
            this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Size = new System.Drawing.Size(47, 35);
            this.toolStripButton1.Text = "Nuovo";
            this.toolStripButton1.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
            this.toolStripButton1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            // 
            // toolStripButton3
            // 
            this.toolStripButton3.Image = global::Scenario.Tools.Consolle.Properties.Resources.apriToolStripMenuItem_Image;
            this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton3.Name = "toolStripButton3";
            this.toolStripButton3.Size = new System.Drawing.Size(33, 35);
            this.toolStripButton3.Text = "Apri";
            this.toolStripButton3.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
            this.toolStripButton3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            this.toolStripButton3.ToolTipText = "Apri";
            // 
            // toolStripButton2
            // 
            this.toolStripButton2.Image = global::Scenario.Tools.Consolle.Properties.Resources.toolStripButton2_Image;
            this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton2.Name = "toolStripButton2";
            this.toolStripButton2.Size = new System.Drawing.Size(38, 35);
            this.toolStripButton2.Text = "Salva";
            this.toolStripButton2.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
            this.toolStripButton2.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            this.toolStripButton2.ToolTipText = "Salva";
            // 
            // toolStripSeparator1
            // 
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new System.Drawing.Size(6, 38);
            // 
            // toolStripButton4
            // 
            this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton4.Name = "toolStripButton4";
            this.toolStripButton4.Size = new System.Drawing.Size(43, 35);
            this.toolStripButton4.Text = "Eventi";
            this.toolStripButton4.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
            this.toolStripButton4.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            this.toolStripButton4.ToolTipText = "Salva";
            // 
            // toolStripPartecipants
            // 
            this.toolStripPartecipants.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripPartecipants.Name = "toolStripPartecipants";
            this.toolStripPartecipants.Size = new System.Drawing.Size(74, 35);
            this.toolStripPartecipants.Text = "Partecipanti";
            this.toolStripPartecipants.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
            this.toolStripPartecipants.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            this.toolStripPartecipants.ToolTipText = "Salva";
            // 
            // toolStripButton5
            // 
            this.toolStripButton5.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton5.Name = "toolStripButton5";
            this.toolStripButton5.Size = new System.Drawing.Size(61, 35);
            this.toolStripButton5.Text = "DataType";
            this.toolStripButton5.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
            this.toolStripButton5.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            this.toolStripButton5.ToolTipText = "Salva";
            // 
            // toolStripButton6
            // 
            this.toolStripButton6.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton6.Name = "toolStripButton6";
            this.toolStripButton6.Size = new System.Drawing.Size(72, 35);
            this.toolStripButton6.Text = "Application";
            this.toolStripButton6.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
            this.toolStripButton6.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            this.toolStripButton6.ToolTipText = "Salva";
            // 
            // toolStripSeparator2
            // 
            this.toolStripSeparator2.Name = "toolStripSeparator2";
            this.toolStripSeparator2.Size = new System.Drawing.Size(6, 38);
            // 
            // toolStripButton7
            // 
            this.toolStripButton7.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton7.Name = "toolStripButton7";
            this.toolStripButton7.Size = new System.Drawing.Size(64, 35);
            this.toolStripButton7.Text = "Convalida";
            this.toolStripButton7.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
            this.toolStripButton7.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            this.toolStripButton7.ToolTipText = "Salva";
            // 
            // toolStripSeparator3
            // 
            this.toolStripSeparator3.Name = "toolStripSeparator3";
            this.toolStripSeparator3.Size = new System.Drawing.Size(6, 38);
            // 
            // toolStripButton8
            // 
            this.toolStripButton8.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.creatToolStripMenuItem,
            this.eseguiToolStripMenuItem,
            this.apriToolStripMenuItem,
            this.restartToolStripMenuItem});
            this.toolStripButton8.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton8.Name = "toolStripButton8";
            this.toolStripButton8.Size = new System.Drawing.Size(121, 35);
            this.toolStripButton8.Text = "Workflow Instance";
            this.toolStripButton8.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;
            this.toolStripButton8.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
            this.toolStripButton8.ToolTipText = "Salva";
            // 
            // creatToolStripMenuItem
            // 
            this.creatToolStripMenuItem.Name = "creatToolStripMenuItem";
            this.creatToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
            this.creatToolStripMenuItem.Text = "Crea";
            // 
            // eseguiToolStripMenuItem
            // 
            this.eseguiToolStripMenuItem.Name = "eseguiToolStripMenuItem";
            this.eseguiToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
            this.eseguiToolStripMenuItem.Text = "Esegui";
            // 
            // apriToolStripMenuItem
            // 
            this.apriToolStripMenuItem.Name = "apriToolStripMenuItem";
            this.apriToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
            this.apriToolStripMenuItem.Text = "Apri";
            // 
            // restartToolStripMenuItem
            // 
            this.restartToolStripMenuItem.Name = "restartToolStripMenuItem";
            this.restartToolStripMenuItem.Size = new System.Drawing.Size(110, 22);
            this.restartToolStripMenuItem.Text = "Restart";
            // 
            // statusStrip1
            // 
            this.statusStrip1.Location = new System.Drawing.Point(0, 295);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new System.Drawing.Size(801, 22);
            this.statusStrip1.TabIndex = 9;
            this.statusStrip1.Text = "statusStrip1";
            // 
            // pnlBottom
            // 
            this.pnlBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.pnlBottom.Location = new System.Drawing.Point(0, 276);
            this.pnlBottom.Name = "pnlBottom";
            this.pnlBottom.Size = new System.Drawing.Size(801, 19);
            this.pnlBottom.TabIndex = 10;
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.workflowList1);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel1.Location = new System.Drawing.Point(0, 38);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(801, 238);
            this.panel1.TabIndex = 11;
            // 
            // workflowList1
            // 
            this.workflowList1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.workflowList1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.workflowList1.Location = new System.Drawing.Point(0, 0);
            this.workflowList1.Name = "workflowList1";
            this.workflowList1.Size = new System.Drawing.Size(801, 238);
            this.workflowList1.TabIndex = 0;
            this.workflowList1.XMLWorkflows = null;
            // 
            // MainForm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(801, 317);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.pnlBottom);
            this.Controls.Add(this.statusStrip1);
            this.Controls.Add(this.toolStrip1);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Menu = this.mainMenu1;
            this.Name = "MainForm";
            this.Text = "Scenario Framework Consolle";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.Load += new System.EventHandler(this.MainForm_Load);
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            this.panel1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
            String sConfigurationFile = String.Empty;

            try
            {
                System.Configuration.Configuration config =
                    ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                AppSettingsSection appSettingSection =
                    (AppSettingsSection)config.GetSection("appSettings");

                sConfigurationFile = appSettingSection.Settings["CriteriaConfgiruationFile"].Value;
            }
            catch (Exception err)
            {
                System.Diagnostics.Debug.WriteLine(err.Message);
            }

            try
            {
                Scenario.WorkflowEngine.Engine.Instance.StartUp(sConfigurationFile, false);
            }
            catch ( Scenario.WorkflowEngine.EngineException err)
            {
				MessageBox.Show (err.Message);
				return;
			}
			
			System.Windows.Forms.Application.Run(new MainForm());

            try
            {
                Scenario.WorkflowEngine.Engine.Instance.ShutDown();
            }
            catch (Scenario.WorkflowEngine.EngineException err)
            {
                MessageBox.Show(err.Message);
                return;
            }
		}
        
		#region Menu Event

		private void mnuOpenInstance_Click(object sender, System.EventArgs e)
		{
			
		}

		private void menuCheck_Click(object sender, System.EventArgs e)
		{
			System.Xml.XmlDocument document = new System.Xml.XmlDocument();

			try
			{
				string sDirectory = Engine.FolderHelper.GetFolder(FolderHelper.FolderType.CheckList);
				string sFileManager = sDirectory + "\\checkslist.xml";

				document.Load (sFileManager);
				System.Xml.XmlNode root = document.FirstChild;

				//this.BuildModel();
				for ( int i=0; i<root.ChildNodes.Count;i++)
				{
					Scenario.Modeler.Forms.XSLTCheck formCheck = new Scenario.Modeler.Forms.XSLTCheck();
					formCheck.XSLT = sDirectory + "\\"  + root.ChildNodes[i].Attributes["File"].Value + ".xslt";
			
					WorkflowProcesses.XMLWorkflow xmlWorkflow = null;

					for ( int j=0; j<this.xmlWorkflows.Count;j++)
					{
						xmlWorkflow = (WorkflowProcesses.XMLWorkflow )this.xmlWorkflows[j];

						formCheck.XML = xmlWorkflow.GetXML();

						formCheck.ShowDialog (this);
					}

				}
			}
			catch (System.Xml.XmlException err)
			{
				System.Console.WriteLine ("Error reading checklist.xml [ {0} ]", err.Message);
			}
		}

		private void menuTutorial_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show ("TODO");
		}

		private void menuManual_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show ("TODO");
		}

		private void menuAboutScenario_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show ("TODO");
		}

		private void menuAboutModeler_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show ("TODO");
		}

		private void menuWWWLinks_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show ("TODO");
		}

		private void menuCreateModel_Click(object sender, System.EventArgs e)
		{
			
		}

		private void menuResources_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show ("TODO");
		}

		private void menuNew_Click(object sender, System.EventArgs e)
		{
			
		}

		private void menuRecentFiles_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show ("TODO");
		}

		private void menuExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
			System.Windows.Forms.Application.Exit();
		}

		private void menuDataTypes_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show ("TODO");
		}

		private void menuApplications_Click(object sender, System.EventArgs e)
		{
			Applications applications = new Applications();
			applications.ShowDialog (this);
		}

		private void menuPartecipants_Click(object sender, System.EventArgs e)
		{
			Participants participants = new Participants(xmlRoles);
			participants.ShowDialog (this);

			if ( participants.xmlRoles != null )
			{
				this.xmlRoles = participants.xmlRoles;
			}
		}

		private void menuManageCheck_Click(object sender, System.EventArgs e)
		{
			Scenario.Modeler.Forms.XSLTFilesManager manager = new Scenario.Modeler.Forms.XSLTFilesManager();
			//manager.MainForm = this;
			manager.ShowDialog (this);
		}

		#endregion

		private void mnuXSDEditor_Click(object sender, System.EventArgs e)
		{
			xmlSchemaEditor.SchemaEditor form = new xmlSchemaEditor.SchemaEditor();
			form.Show();
		}

		private void menuXMLDB_Click(object sender, System.EventArgs e)
		{
			xmlDbEditor.Form1 form = new xmlDbEditor.Form1();
			form.Show();
		}

		private void menuXSDInference_Click(object sender, System.EventArgs e)
		{
			Scenario.Modeler.XSD.XSDInference form = new Scenario.Modeler.XSD.XSDInference();
			form.Show();
		}

		private void mnuSendFeedBack_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show ("TODO");
		}

        private void menuConfiguration_Click(object sender, EventArgs e)
        {

        }

        private void menuEnd_Click(object sender, EventArgs e)
        {
            this.Close();
            System.Windows.Forms.Application.Exit();
        }

        private void menuInstanceOpen_Click(object sender, EventArgs e)
        {
            Scenario.Forms.Workflow.ProcessesList processList = new Scenario.Forms.Workflow.ProcessesList();
            processList.ShowDialog();

        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            

        }

        private void mnuStartTemplate_Click(object sender, EventArgs e)
        {
            StartProcess form = new StartProcess();
            form.ShowDialog(this);
        }

       
	}
}
